from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By
#创建一个浏览器实例
#driver = webdriver.Chrome()
driver = webdriver.Edge()
driver.get("http://www.baidu.com")

#<a href="https://www.hao123.com?src=from_pc_logon" target="_blank" class="mnav c-font-normal c-color-t">
a = driver.find_element(By.LINK_TEXT,"hao123")
print(a.text)
print(a.get_dom_attribute("href"))
print(a.get_dom_attribute("class"))
print(a.get_dom_attribute("target"))

b = driver.find_element(By.PARTIAL_LINK_TEXT,"hao")
print(b.text)
print(b.get_dom_attribute("href"))
print(b.get_dom_attribute("class"))
print(b.get_dom_attribute("target"))